package com.ripplezjw.blog.controller.admin;

import com.ripplezjw.blog.Service.ArticleService;
import com.ripplezjw.blog.Service.ClassificationService;
import com.ripplezjw.blog.Service.TagService;
import com.ripplezjw.blog.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    ArticleService articleService;
    @Autowired
    UserService userService;
    @Autowired
    ClassificationService classificationService;
    @Autowired
    TagService tagService;

    @GetMapping("/articleMan")
    public String articleMan(Model model) {
        model.addAttribute("cur_page", "articleMan");
        model.addAttribute("articles", articleService.showAllArticle());
        return "/admin/articleMan";
    }

    @GetMapping("/classificationMan")
    public String classificationMan(Model model) {
        model.addAttribute("cur_page", "classificationMan");
        model.addAttribute("clss", classificationService.showAllCls());
        return "/admin/classificationMan";
    }

    @GetMapping("/tagMan")
    public String tagMan(Model model) {
        model.addAttribute("cur_page", "tagMan");
        model.addAttribute("tags", tagService.showAllTags());
        return "/admin/tagMan";
    }

    @GetMapping("/userMan")
    public String userMan(Model model) {
        model.addAttribute("cur_page", "userMan");
        model.addAttribute("users", userService.showAllUsers());
        return "/admin/userMan";
    }
}
